function M = methods(S)
% BVQXfile::methods  - overloaded method
%
% gives the available methods for the current object (see subsref)

% Version:  v0.7f
% Build:    8110521
% Date:     Nov-05 2008, 9:00 PM CET
% Author:   Jochen Weber, SCAN Unit, Columbia University, NYC, NY, USA
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% persistent methods
persistent bvqxfile_methods;
if isempty(bvqxfile_methods)
    bvqxfile_methods = BVQXfile(0, 'methods');
end

% default to empty
M = {};

% only valid if not empty
if isempty(S)
    return;
end

% get structed version and lookup
sfile = struct(S);
if ~isempty(sfile)
    try
        sc = bvqxfile_getscont(sfile(1).L);
    catch
        error( ...
            'BVQXfile:InvalidObject', ...
            'Memory of object freed.' ...
        );
    end
end

% get file type and set
stype = lower(sc.S.Extensions{1});

% add methods for this type if any
if isfield(bvqxfile_methods, stype)
    tm = bvqxfile_methods.(stype);
    mf = fieldnames(tm);

    % iterate
    M = cell(numel(mf), 1);
    for mc = 1:length(mf)
        sm = tm.(mf{mc}){1};
        up = find(sm == '_');
        M{mc} = sm(up(1)+1:end);
    end
end

% add AFT methods
tm = bvqxfile_methods.aft;
mf = fieldnames(tm);

% iterate
nM = numel(M);
M{nM + numel(mf)} = ''; 
for mc = 1:length(mf)
    sm = tm.(mf{mc}){1};
    M{nM + mc} = sm(5:end);
end
